package drds.binlog.example.db.dialect;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
 * An enumeration wrapper around JDBC table types.
 */
public enum TableType
{


    /**
     * Table
     */
    table,

    /**
     * View
     */
    view;


    /**
     * Converts an array of table types to an array of their corresponding string values.
     *
     * @param tableTypes Array of table types
     * @return Array of string table types
     */
    public static String[] toStrings(final TableType[] tableTypes)
    {
        if ((tableTypes == null) || (tableTypes.length == 0))
        {
            return new String[0];
        }

        final List<String> tableTypeStrings = new ArrayList<String>(tableTypes.length);

        for (final TableType tableType : tableTypes)
        {
            if (tableType != null)
            {
                tableTypeStrings.add(tableType.toString().toUpperCase(Locale.ENGLISH));
            }
        }

        return tableTypeStrings.toArray(new String[tableTypeStrings.size()]);
    }


}
